package com.scau.service.impl.business;

import java.io.Serializable;

import org.springframework.stereotype.Component;

import com.scau.exception.BusinessException;
import com.scau.model.business.Material;
import com.scau.service.BaseService;

@Component
public class MaterialService extends BaseService<Material> implements Serializable{
	public void save(Material m) throws BusinessException{
		if (null != m && null != m.getMaterial_id()) {
			if(null != m.getId()&& 0 != m.getId()){
				update(m);
			}else{
				add(m);
			}
		}else {
			throw new BusinessException("料号不能为空");
		}
	}
	
	@Override
	public Material get(Material entity){
		if(null!=entity&&null!=entity.getId()&&0!=entity.getId()){
			return super.get(entity, entity.getId());
		}else if (null!=entity) {
			return super.get(entity);
		}else {
			return null;
		}
	}
}
